package VN.EDU.IMIC.DEVELOPER.TRANTHITHANHNGA.EXJSON;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

import org.codehaus.jackson.map.ObjectMapper;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

import com.google.gson.Gson;

public class ApiToList {

	/**
	 * @param args
	 * @throws
	 */
	public static void main(String[] args) throws Exception {

		URL url = new URL(
				"http://voer.edu.vn/c/vaora-voi-stream-trong-java/761b0302/528c577d");
		BufferedReader in = new BufferedReader(new InputStreamReader(
				url.openStream()));
		String input = in.readLine();

		String Path = "C:\\JSONFiles\\APIToJSONFiles.json";
		Gson objG = new Gson();
		String JsonString = objG.toJson(in);
		FileWriter objFW;
		try {
			objFW = new FileWriter(new File(Path));
			objFW.write(JsonString);
			objFW.close();
		} catch (IOException e) {
			System.out.println("loi" + e.getMessage());
		}
		System.out.println("ok");
	}
}